import React, { Component } from 'react'
import './Item.css'
export default class Item extends Component {
  // 修改状态，获取id返回app修改
  updateHandle = (id) => {
    return (e) => {
    // console.log(id);
      this.props.getTodoIdUpdate(id);
      
    };
  }
  // 删除一条数据
  Delhandle = (id) => (e) => {this.props.getTodoIdDelete(id);}

  
  render() {
    const { todo } = this.props;
    return (
      <li>
        <label>
          <input
            type="checkbox"
            checked={todo.isDone}
            onChange={this.updateHandle(todo.id)}
          />
          <span className={todo.isDone ? "active" : ""}>{todo.todoName}</span>
        </label>
        <button className="btn btn-danger" onClick={this.Delhandle(todo.id)}>
          删除
        </button>
      </li>
    );
  }
}
